const arr = [...Array.from({
	length: 10000000
}).keys()];

(function() {
	console.time("for-let");
	var res = 0;
	for (let i = 0, len = arr.length; i < len; i += 1) {
		const item = arr[i];
		res += item;
	}
	console.log(res);
	console.timeEnd("for-let");
}());
(function() {
	console.time("for-of-let");
	var res = 0;
	for (let item of arr) {
		res += item;
	}
	console.log(res);
	console.timeEnd("for-of-let");
}());
(function() {
	console.time("for-of-var");
	var res = 0;
	for (var item of arr) {
		res += item;
	}
	console.log(res);
	console.timeEnd("for-of-var");
}());
(function() {
	console.time("forEach");
	var res = 0;
	arr.forEach(function(item) {
		res += item
	});
	console.log(res);
	console.timeEnd("forEach");
}());
(function() {
	console.time("forEach-nofun");
	var res = 0;
	arr.forEach(item => {
		res += item
	});
	console.log(res);
	console.timeEnd("forEach-nofun");
}());
(function() {
	console.time("reduce");
	var res = 0;
	res = arr.reduce(function(pre_v, item) {
		return pre_v + item
	}, res);
	console.log(res);
	console.timeEnd("reduce");
}());
(function() {
	console.time("reduce-nofun");
	var res = 0;
	res = arr.reduce((pre_v, item) => pre_v + item, res);
	console.log(res);
	console.timeEnd("reduce-nofun");
}());
(function() {
	console.time("for-var");
	var res = 0;
	var i, item;
	for (i = 0, len = arr.length; i < len; i += 1) {
		item = arr[i];
		res += item;
	}
	console.log(res);
	console.timeEnd("for-var");
}());